package com.woniu.admin.vo;

import lombok.Data;

@Data
public class AjaxResult {
    private Integer code;
    private String msg;
    private Object data;

    private static final Integer SUCCESS = 200;
    private static final Integer ERROR = 500;

    public AjaxResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public static AjaxResult success(String msg, Object data) {
        return new AjaxResult(SUCCESS, msg, data);
    }

    public static AjaxResult success(String msg) {
        return new AjaxResult(SUCCESS, msg, null);
    }

    public static AjaxResult error(String msg, Object data) {
        return new AjaxResult(ERROR, msg, data);
    }

    public static AjaxResult error(String msg) {
        return new AjaxResult(ERROR, msg, null);
    }
}
